<html>
<head><meta charset="utf-8"><title>Require user selection from an action · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html">Require user selection from an action</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="184436691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184436691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184436691">(Dec 29 2019 at 21:19)</a>:</h4>
<p>One more thing related to the <a href="https://github.com/rust-analyzer/rust-analyzer/issues/2180" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/2180">https://github.com/rust-analyzer/rust-analyzer/issues/2180</a> implementation I would like to discuss.</p>
<p>There can be multiple items with the same name to import  in the project, so we need to provide some kind of a dialogue for a user with all possible import options (that's what intellij-rust does now) and the ability to proceed the action with the user selection.</p>
<p>Is there anything in RA I can use for that?<br>
If not, IMO it makes sense to make it possible before implementing the auto import functionality and I would appreciate any guidance.</p>



<a name="184437804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184437804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184437804">(Dec 29 2019 at 21:52)</a>:</h4>
<p>Now, we don't but we badly need this for many assists. I am not sure if this can be implemented via the LSP</p>



<a name="184438317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184438317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184438317">(Dec 29 2019 at 22:08)</a>:</h4>
<blockquote>
<p>I am not sure if this can be implemented via the LSP</p>
</blockquote>
<p>That sounds a bit sad, especially for auto import case where false-positive rate is really high, I don't think we can go far with inserting the very first import we get from the action.</p>
<p>Should we reconsider the approach to auto import then and make it something else but an action?<br>
We have some way to interact with VS Code UI at least, since there's <code>Show Syntax Tree</code> functionality that is able to open an external window.</p>
<p>I wish I knew any place to ask LSP-related guys about that functionality, that would be so much better direction to move forward.</p>



<a name="184438648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184438648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184438648">(Dec 29 2019 at 22:19)</a>:</h4>
<blockquote>
<p>I wish I knew any place to ask LSP-related guys about that functionality, that would be so much better direction to move forward.</p>
</blockquote>
<p>THe best way is to just re-check how LSP speck says actions should work, and if we can use them. At worst, we  can do what run configurations do: hand-crafted cleint-side option picker</p>



<a name="184467355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184467355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184467355">(Dec 30 2019 at 11:42)</a>:</h4>
<blockquote>
<p>At worst, we can do what run configurations do: hand-crafted cleint-side option picker</p>
</blockquote>
<p>I've looked through the spec and so far it looks like this is the only way we can do it currently: we need to register a custom command and do the magic there.</p>



<a name="184470008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184470008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184470008">(Dec 30 2019 at 12:41)</a>:</h4>
<p>IIRC, it's possible to return a command name &amp; args from an action, so I think our intentions should return smth like this:</p>
<div class="codehilite"><pre><span></span>{
  &quot;command&quot;: &quot;ra-lsp.choose-action&quot;,
  &quot;args&quot;: [[[&quot;import foo&quot;, SOurceChange1], [&quot;import bar&quot;, SOurceChange1]]]
}
</pre></div>



<a name="184472469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184472469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184472469">(Dec 30 2019 at 13:29)</a>:</h4>
<p>Yep, that's what I was planning to do either.<br>
I'll come up with something later.</p>



<a name="184566070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Require%20user%20selection%20from%20an%20action/near/184566070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Require.20user.20selection.20from.20an.20action.html#184566070">(Dec 31 2019 at 21:09)</a>:</h4>
<p>I think I've found a way to do this without any extra commands created: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/2716" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/2716">https://github.com/rust-analyzer/rust-analyzer/pull/2716</a></p>
<p>The only issue with this PR is that the CI fails to run the tests and does not show me the logs.<br>
<code>cargo test</code> passes for me locally, so I have no idea what's wrong.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>